package com.bcpapp.project.task;


import com.bcpapp.project.constant.RLConstant;
import com.bcpapp.project.service.*;
import com.bcpapp.project.utils.FileUtils;
import com.bcpapp.project.utils.TimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class TaskServer {

    @Autowired
    private ReLiService reLiService;

    public void rlQHTask(){

        log.info("进入定时任务1");
        String lastDateStr = TimeUtils.getLastDateStr();
        /*
         * 区划迁入迁出驻留分析接口
         * */
        reLiService.populationsituationday(lastDateStr);

        /*
        *  区划迁徙总览接口的
        * https://apis.map.qq.com/bigdata/realtime/v1/adcodemigration
        * paramMap.put("date", "2023-11-02");
        * */
        reLiService.adcodemigration(lastDateStr);

        /*
         * https://apis.map.qq.com/bigdata/realtime/v1.1/predictpopulation
         * 区域实时人数预测
         * */
        for (String idKey: RLConstant.regionIdKey ) {
        reLiService.predictpopulation(idKey);
        }
    }

    public void rlQYTask(){
        log.info("进入定时任务2");


        for (String idKey: RLConstant.regionIdKey ) {

        Integer[] twoHour = TimeUtils.getTwoHour();
        /*
         * 区域实时累计人流接口
         * */
        reLiService.flowsum(idKey,twoHour[0],twoHour[1]);
        /*
         *
         *   https://apis.map.qq.com/bigdata/realtime/v1.1/population
         * 据区域实时人数接口
         * */
        reLiService.population(idKey,twoHour[0],twoHour[1]);

        /*
         * 区域实时人口热力
         *
         * https://apis.map.qq.com/bigdata/realtime/v1.1/locationpoint
         * */
        reLiService.locationpoint(idKey,twoHour[0],twoHour[1]);
        /*
         *
         * 区域实时人流接口
         *
         * https://apis.map.qq.com/bigdata/realtime/v1.1/flow
         * */
        reLiService.flow(idKey,twoHour[0],twoHour[1]);
        /*
         * https://apis.map.qq.com/bigdata/realtime/v1.1/userprofile
         * 区域实时人口画像接口的
         * */
        reLiService.userprofile(idKey,twoHour[0],twoHour[1]);
        }

    }

}
